/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Thai Dac Vinh
 */
@Entity
@Table(name = "MONEYTRANSFERLOG")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Moneytransferlog.findAll", query = "SELECT m FROM Moneytransferlog m"),
    @NamedQuery(name = "Moneytransferlog.findByTransferdate", query = "SELECT m FROM Moneytransferlog m WHERE m.moneytransferlogPK.transferdate = :transferdate"),
    @NamedQuery(name = "Moneytransferlog.findBySenderaccount", query = "SELECT m FROM Moneytransferlog m WHERE m.moneytransferlogPK.senderaccount = :senderaccount"),
    @NamedQuery(name = "Moneytransferlog.findByReceiveraccount", query = "SELECT m FROM Moneytransferlog m WHERE m.moneytransferlogPK.receiveraccount = :receiveraccount"),
    @NamedQuery(name = "Moneytransferlog.findByAmount", query = "SELECT m FROM Moneytransferlog m WHERE m.amount = :amount"),
    @NamedQuery(name = "Moneytransferlog.findByDetails", query = "SELECT m FROM Moneytransferlog m WHERE m.details = :details")})
public class Moneytransferlog implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MoneytransferlogPK moneytransferlogPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AMOUNT")
    private float amount;
    @Size(max = 50)
    @Column(name = "DETAILS")
    private String details;
    @JoinColumn(name = "SENDERACCOUNT", referencedColumnName = "AID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Account senderAccount;
    @JoinColumn(name = "RECEIVERACCOUNT", referencedColumnName = "AID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Account receiverAccount;

    public Moneytransferlog() {
    }

    public Moneytransferlog(MoneytransferlogPK moneytransferlogPK) {
        this.moneytransferlogPK = moneytransferlogPK;
    }

    public Moneytransferlog(MoneytransferlogPK moneytransferlogPK, float amount) {
        this.moneytransferlogPK = moneytransferlogPK;
        this.amount = amount;
    }

    public Moneytransferlog(Date transferdate, String senderaccount, String receiveraccount) {
        this.moneytransferlogPK = new MoneytransferlogPK(transferdate, senderaccount, receiveraccount);
    }

    public MoneytransferlogPK getMoneytransferlogPK() {
        return moneytransferlogPK;
    }

    public void setMoneytransferlogPK(MoneytransferlogPK moneytransferlogPK) {
        this.moneytransferlogPK = moneytransferlogPK;
    }

    public float getAmount() {
        return amount;
    }

    public void setAmount(float amount) {
        this.amount = amount;
    }

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public Account getSenderAccount() {
        return senderAccount;
    }

    public void setSenderAccount(Account account) {
        this.senderAccount = account;
    }

    public Account getReceiverAccount() {
        return receiverAccount;
    }

    public void setReceiverAccount(Account account) {
        this.receiverAccount = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (moneytransferlogPK != null ? moneytransferlogPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Moneytransferlog)) {
            return false;
        }
        Moneytransferlog other = (Moneytransferlog) object;
        if ((this.moneytransferlogPK == null && other.moneytransferlogPK != null) || (this.moneytransferlogPK != null && !this.moneytransferlogPK.equals(other.moneytransferlogPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Moneytransferlog[ moneytransferlogPK=" + moneytransferlogPK + " ]";
    }
    
}
